package com.etone.smartAudit.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.etone.smartAudit.commService.CommPUumUserinfoService;
import com.etone.smartAudit.domain.Admin;
import com.etone.smartAudit.domain.PDict;
import com.etone.smartAudit.domain.PUumUserinfo;
import com.etone.smartAudit.error.CustomParameterizedException;
import com.etone.smartAudit.mapper.AdminMapper;
import com.etone.smartAudit.vo.PUumUserinfoVO;
import com.etone.smartAudit.vo.workOrder.AuditManVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 张任豪
 */
@Service
@AllArgsConstructor
public class WorkOrderItemService {

    private PDictService pDictService;

    private AdminMapper adminMapper;

    private CommPUumUserinfoService commPUumUserinfoService;

    public List<PUumUserinfoVO> getDeptMan(Admin admin, Integer id) {
        //通过用户id查询出port中的账号
        if (id != null) {
            admin = adminMapper.selectById(id);
        }
        try {
            PUumUserinfo pUumUserinfo = commPUumUserinfoService.getOne(new QueryWrapper<PUumUserinfo>().eq("userID", admin.getAccount()));
            List<PUumUserinfoVO> vos = commPUumUserinfoService.getDeptMan(pUumUserinfo.getDepartmentID());
            return vos;
        }catch (Exception e){
            throw new CustomParameterizedException("在portal结构中未找到相应的账号");
        }


    }
}
